//
//  YKRecommendCategoryCellTableViewCell.m
//  百思不得姐
//
//  Created by Eric.Wu on 16/2/25.
//  Copyright © 2016年 Eric.Wu. All rights reserved.
//

#import "YKRecommendCategoryCell.h"
#import "YKCategoryModel.h"

@interface YKRecommendCategoryCell ()
@property (weak, nonatomic) IBOutlet UIView *selectedIndicator;

@end
@implementation YKRecommendCategoryCell

+  (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"category";
    YKRecommendCategoryCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
    }
    return cell;

}

- (void)setCategory:(YKCategoryModel *)category
{
    _category = category;
    self.textLabel.font = [UIFont systemFontOfSize:12];
    self.textLabel.text = category.name;
}

- (void)awakeFromNib
{
//    self.backgroundColor = [UIColor darkGrayColor];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    self.selectedIndicator.hidden = !selected;
    
    self.textLabel.textColor = selected? YKColor(192, 62, 66):[UIColor darkGrayColor];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.textLabel.y = 2;
    self.textLabel.width = self.contentView.width;
    self.textLabel.height = self.contentView.height - 2*self.textLabel.y;
}

@end
